#include <zenoui/widgets/EmptyWidget.hpp>
#include <zenoui/check_gl.hpp>

namespace zenoui {

void EmptyWidget::paint() { // fill rect with the background color property
    if (m_background_color.a <= 0.0f) return;
    auto myrect = rect();

    glBegin(GL_QUADS);
    glColor4fv(glm::value_ptr(m_background_color));
    glVertex2f(myrect.m_topleft.x, myrect.m_topleft.y);
    glVertex2f(myrect.m_topleft.x + myrect.m_size.x, myrect.m_topleft.y);
    glVertex2f(myrect.m_topleft.x + myrect.m_size.x, myrect.m_topleft.y + myrect.m_size.y);
    glVertex2f(myrect.m_topleft.x, myrect.m_topleft.y + myrect.m_size.y);
    CHECK_GL(glEnd());
}

void EmptyWidget::property(BackgroundColorProperty *prop) {
    prop->by_ref(m_background_color);
}

}
